home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
tex
/
td187src.lzh
/
DIVERSES.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
6KB
|
264 lines
IMPLEMENTATION MODULE Diverses;
FROM SYSTEM IMPORT ADDRESS;
FROM Types IMPORT Block;
IMPORT MagicAES,
MagicStrings,
MagicSys,
MagicVDI,
mtAlerts,
mtAppl,
MathLib0,
RSCindices;
(**
IMPORT RTD;
**)
PROCEDURE round(real : LONGREAL) : INTEGER;
(* Gerundeten Wert *)
BEGIN
IF real<0.0 THEN
RETURN -MagicSys.CastToInt( MathLib0.entier(-real + 0.5));
ELSE
RETURN MagicSys.CastToInt( MathLib0.entier(real + 0.5));
END;
END round;
PROCEDURE max(a, b : INTEGER) : INTEGER;
BEGIN
IF a>b THEN
RETURN a;
ELSE
RETURN b;
END;
END max;
PROCEDURE min(a, b : INTEGER) : INTEGER;
BEGIN
IF a>b THEN
RETURN b;
ELSE
RETURN a;
END;
END min;
PROCEDURE BlockIntersect(a, b : Block ; VAR bsect : Block) : BOOLEAN ;
(* liefert in <bsect> die Schnittfläche von <a> und <b>,
desweiteren TRUE wenn Schnitt vorlag *)
BEGIN
bsect.x := max(a.x, b.x) ;
bsect.y := max(a.y, b.y) ;
bsect.w := min(a.x + a.w, b.x + b.w) - bsect.x ;
bsect.h := min(a.y + a.h, b.y + b.h) - bsect.y ;
RETURN (bsect.w > 0) AND (bsect.h > 0)
END BlockIntersect ;
VAR MausForm : INTEGER;
MausOns : INTEGER;
PROCEDURE Alert (def: INTEGER; str: ARRAY OF CHAR): INTEGER;
VAR res : INTEGER;
BEGIN
IF DialCentered THEN
res := mtAlerts.Alert(def, str);
ELSE
res := mtAlerts.MouseAlert(def, str);
END;
RETURN res;
END Alert;
CONST MaxAlertNum = 27;
MaxFselNum = 10;
MaxHelpNum = 46;
PROCEDURE NumAlert (alertnum, default : INTEGER) : INTEGER;
VAR result, count, i : INTEGER;
Tree : POINTER TO ARRAY [0..255] OF MagicAES.OBJECT;
tempstr, rscstr : ARRAY [0..255] OF CHAR;
brackstr1,
brackstr2, midstr : ARRAY [0..1] OF CHAR;
BEGIN
brackstr1 := '[';
brackstr2 := ']';
midstr := '|';
tempstr := '';
result := -1;
IF (alertnum>0) AND (alertnum<=MaxAlertNum) THEN
Tree := MagicAES.RsrcGaddr( MagicAES.RTREE , RSCindices.alerts ) ;
count := alertnum-1;
i := 1;
WHILE (count>0) DO
(**
RTD.ShowVar('indx', i);
RTD.ShowVar('Next', Tree^[i].obNext);
RTD.ShowVar('Head', Tree^[i].obHead);
RTD.ShowVar('Tail', Tree^[i].obTail);
**)
i := Tree^[i].obNext;
DEC(count);
END;
FOR count := Tree^[i].obHead TO Tree^[i].obTail DO
MagicStrings.Assign(Tree^[count].StringPtr^, rscstr);
(**
RTD.Write('rscstr', rscstr);
**)
IF count=Tree^[i].obHead THEN
MagicStrings.Assign(rscstr, tempstr);
MagicStrings.Insert(brackstr1, tempstr, 1);
MagicStrings.Insert(brackstr2, tempstr, 1);
MagicStrings.Insert(brackstr1, tempstr, 0);
ELSIF count=Tree^[i].obTail THEN
MagicStrings.Append(brackstr2, tempstr);
MagicStrings.Append(brackstr1, tempstr);
MagicStrings.Append(rscstr, tempstr);
MagicStrings.Append(brackstr2, tempstr);
ELSE
MagicStrings.Append(midstr, tempstr);
MagicStrings.Append(rscstr, tempstr);
END;
END;
(**
RTD.Write('tempstr', tempstr);
**)
IF tempstr[0]<>0C THEN
result := Alert(default, tempstr);
END;
END;
(**
RTD.ShowVar('resut', result);
**)
RETURN result;
END NumAlert;
PROCEDURE GetText(tree, num : INTEGER; VAR txt : ARRAY OF CHAR);
VAR Tree : POINTER TO ARRAY [0..255] OF MagicAES.OBJECT;
BEGIN
txt[0] := 0C;
Tree := MagicAES.RsrcGaddr( MagicAES.RTREE , tree ) ;
MagicStrings.Assign(Tree^[num].StringPtr^, txt);
END GetText;
PROCEDURE GetHelpText(num : INTEGER; VAR txt : ARRAY OF CHAR);
BEGIN
IF (num>0) AND (num<=MaxHelpNum) THEN
GetText(RSCindices.helptxt, num, txt);
END;
END GetHelpText;
PROCEDURE GetFSelText(num : INTEGER; VAR txt : ARRAY OF CHAR);
BEGIN
IF (num>0) AND (num<=MaxFselNum) THEN
GetText(RSCindices.flsltxt, num, txt);
END;
END GetFSelText;
(*----------------------------------------------------------------------*
* Mäusetreiberei *
*----------------------------------------------------------------------*)
PROCEDURE MouseOn;
BEGIN
INC(MausOns);
IF MausOns=1 THEN
(**
RTD.Message('Call MagicVDI.ShowCursor');
**)
MagicVDI.ShowCursor (mtAppl.VDIHandle, FALSE);
(**
RTD.Message('Call ready...');
**)
END;
(**
RTD.Message('Call MagicAES.GrafMouse');
**)
MagicAES.GrafMouse (MausForm, NIL);
(**
RTD.Message('Call ready...');
**)
END MouseOn;
PROCEDURE MouseArrow;
BEGIN
MausForm:= MagicAES.ARROW; MouseOn;
END MouseArrow;
PROCEDURE MouseCursor;
BEGIN
MausForm:= MagicAES.TEXTCRSR; MouseOn;
END MouseCursor;
PROCEDURE MouseBusy;
BEGIN
MausForm:= MagicAES.BUSYBEE; MouseOn;
END MouseBusy;
PROCEDURE MouseFinger;
BEGIN
MausForm:= MagicAES.POINTHAND; MouseOn;
END MouseFinger;
PROCEDURE MouseHand;
BEGIN
MausForm:= MagicAES.FLATHAND; MouseOn;
END MouseHand;
PROCEDURE MouseThincross;
BEGIN
MausForm:= MagicAES.THINCROSS; MouseOn;
END MouseThincross;
PROCEDURE MouseThickcross;
BEGIN
MausForm:= MagicAES.THICKCROSS; MouseOn;
END MouseThickcross;
PROCEDURE MouseOutline;
BEGIN
MausForm:= MagicAES.OUTLCROSS; MouseOn;
END MouseOutline;
PROCEDURE MouseUser;
BEGIN
MausForm:= MagicAES.USERDEF; MouseOn;
END MouseUser;
PROCEDURE MouseOff;
BEGIN
DEC(MausOns, 1);
IF (MausOns<=0) THEN
IF (MausOns=0) THEN
MagicVDI.HideCursor (mtAppl.VDIHandle);
END;
MausOns := 0;
END;
END MouseOff;
PROCEDURE ForceMouseOn;
BEGIN
MausOns := 0; MouseOn;
END ForceMouseOn;
PROCEDURE ForceMouseOff;
BEGIN
MausOns := 1; MouseOff;
END ForceMouseOff;
BEGIN
DialCentered := TRUE;
MausOns := 0;
MausForm := MagicAES.ARROW;
END Diverses.